﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for GroupProduct
/// </summary>
public class GroupProductDAL : BaseDAL
{
    public DataSet List(int pageIndex, int pageMax, int groupProductId, int groupParent, int isActive)
    {
        DataSet ds = new DataSet();
        //string[] uspParaName = new string[] { "?pageIndex", "?pageMax", "?groupProductId", "?GroupParent", "?IsActive" };
        //object[] uspParaValue = new object[] { pageIndex, pageMax, groupProductId, groupParent, isActive };
        //string uspName = "usp_groupproduct_listgroupproduct";

        //ds = base.RunProcedure(uspParaName, uspParaValue, uspName);

        string query = string.Format("select * from GroupProduct");
        ds = base.RunQuery(query);

        return ds;
    }
    public DataSet Detail(int groupProductId)
    {
        DataSet ds = new DataSet();
        ds = List(1, 1, groupProductId, 0, -1);
        return ds;
    }
    public DataSet Insert(string groupProductName, int isActive, int groupParent, int status)
    {
        DataSet ds = new DataSet();
        //string[] uspParaName = new string[] { "?GroupProductName", "?IsActive", "?GroupParent", "?Status" };
        //object[] uspParaValue = new object[] { groupProductName, isActive, groupParent, status };
        //string uspName = "usp_groupProduct_insert";

        //ds = base.RunProcedure(uspParaName, uspParaValue, uspName);

        string query = string.Format("insert into GroupProduct (GroupProductName, IsActive, GroupParent,Status) values ('{0}','{1}',{2},{3});Select @@identity as BrandId;", groupProductName, isActive, groupParent, status);
        ds = base.RunQuery(query);

        return ds;
    }
    public DataSet Update(int groupProductId, string groupProductName, int isActive, int groupParent, int status)
    {
        DataSet ds = new DataSet();
        string[] uspParaName = new string[] { "?_groupProductId", "?_GroupProductName", "?_IsActive", "?_GroupParent", "?_Status" };
        object[] uspParaValue = new object[] { groupProductId, groupProductName, isActive, groupParent, status };
        string uspName = "usp_groupProduct_update";

        ds = base.RunProcedure(uspParaName, uspParaValue, uspName);
        return ds;
    }
    public DataSet UpdateStatusActive(int groupProductId, int isActive)
    {
        DataSet ds = new DataSet();
        string query = string.Format("update groupproducts set IsActive={0} where groupProductId={1};", isActive, groupProductId);
        ds = base.RunQuery(query);
        return ds;
    }
}